package net.istore.market.dao.order;

import net.istore.market.dao.AbstractDAO;
import net.istore.market.domain.Order;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Ivan_Zhuravel on 1/8/15.
 */
@Repository
public class OrderDaoImpl extends AbstractDAO implements OrderDao {

    @Override
    public Order addOrder(Order order) {
        return persistEntity(order);
    }

    @Override
    public List<Order> getOrders() {
        return sessionFactory.getCurrentSession().createCriteria(Order.class).list();
    }

    @Override
    public Order getOrder(long orderId) {
        return getEntity(Order.class, orderId);
    }

    @Override
    public Order removeOrder(long id) {
        return remove(Order.class, id);
    }
}
